<!--
  ~ MIT License
  ~
  ~ Copyright (c) 2021-2022 yangrunkang
  ~
  ~ Author: yangrunkang
  ~ Email: yangrunkang53@gmail.com
  ~
  ~ Permission is hereby granted, free of charge, to any person obtaining a copy
  ~ of this software and associated documentation files (the "Software"), to deal
  ~ in the Software without restriction, including without limitation the rights
  ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  ~ copies of the Software, and to permit persons to whom the Software is
  ~ furnished to do so, subject to the following conditions:
  ~
  ~ The above copyright notice and this permission notice shall be included in all
  ~ copies or substantial portions of the Software.
  ~
  ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  ~ SOFTWARE.
  -->

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      th:replace="index">
<!--css-->
<link th:fragment="css" type="text/css" rel="stylesheet" th:href="${ossStatic} + @{/css/search/search.css}"/>
<!--脚本-->
<script async="async" th:fragment="js" type="text/javascript" th:src="${ossStatic} + @{/js/search/search.js}"></script>
<!--内容-->
<div th:fragment="content">
    <!--全局搜索-->
    <div class="container">
        <div class="row g-2">
            <div class="col-lg-9 mb-2">
                <div id="content_more_alert" class="alert alert-danger alert-dismissible fade show mb-2" role="alert" style="display: none">
                    搜索结果已经超过最大限制条数300条,多余的搜索结果将不显示。请进一步完善您的搜索条件以便更加精确的搜索
                    <br />
                    根据搜索条件一共搜到了<span style="font-size: 20px;font-weight: bolder" th:text="${searchIndexDto.total}"></span>条数据,只显示了最新的300条
                    <button type="button" class="btn btn-close rounded-3 bg-gradient-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
                <div style="width: 100%;" class="card card-body shadow-sm border-bottom border-2 border-top-0 border-start border-end-0 border-0 text-center">
                    <h2 style="font-weight: lighter">关键字</h2>
                    <div>
                        <div style="font-size: 30px;color: #00a8c6" id="navbar_search_keyword"></div>
                    </div>
                </div>
                <div>
                    <input type="hidden" id="content_more_alert_value" th:value="${searchIndexDto.total}"/>
                </div>


                <div class="card card-body shadow-sm border-bottom border-2 border-top-0 border-start border-end-0 p-2 my-2">
                    <div th:if="${#lists.isEmpty(searchIndexDto.searchDataDtoList)}" th:include="fragments/index::empty_content"></div>
                    <ul class="list-group list-group-flush" th:if="!${#lists.isEmpty(searchIndexDto.searchDataDtoList)}">
                        <li class="list-group-item p-1" th:each="searchData,ite : ${searchIndexDto.searchDataDtoList}">

                            <div class="d-flex align-items-center" th:if="${searchData.dataType.name()} == 'CONTENT'">
                                <div class="flex-grow-1">
                                    <div class="mt-0">
                                        <a th:href="@{'/u/'+${searchData.resultId}}" class="cv-link up-text-overflow fs-6 fst-normal" th:title="${searchData.resultTitle}">[[${searchData.resultTitle}]]</a>
                                        <span class="badge bg-gradient bg-warning text-dark fw-light rounded-3 small">文章</span>
                                    </div>
                                </div>
                                <a class="flex-shrink-0 text-black-50 cv-link" th:href="'/profile/' + ${searchData.member.userId}+'/content'"  th:title="${searchData.member.userName}">
                                    <img class="lazyload img rounded rounded-right cv-icon-50" th:data-src="${searchData.member.via}" th:alt="${searchData.member.userName}">
                                </a>
                            </div>

                            <div class="d-flex align-items-center" th:if="${searchData.dataType.name()} == 'RADIO'">
                                <div class="flex-grow-1">
                                    <div class="mt-0">
                                        <a th:href="@{'/r/'+${searchData.resultId}}" class="cv-link up-text-overflow fs-6 fst-normal" th:title="${searchData.resultTitle}">[[${searchData.resultTitle}]]</a>
                                        <span class="badge bg-gradient bg-primary fw-light rounded-3 small">电台</span>
                                    </div>
                                </div>
                                <a class="flex-shrink-0 text-black-50 cv-link" th:href="'/profile/' + ${searchData.member.userId}+'/content'"  th:title="${searchData.member.userName}">
                                    <img class="lazyload img rounded rounded-right cv-icon-50" th:data-src="${searchData.member.via}" th:alt="${searchData.member.userName}">
                                </a>
                            </div>

                            <div class="d-flex align-items-center" th:if="${searchData.dataType.name()} == 'MEMBER'">
                                <div class="flex-grow-1">
                                    <div class="mt-0">
                                        <a th:href="'/profile/' + ${searchData.member.userId}+'/content'" class="cv-link up-text-overflow fs-6 fst-normal" th:title="${searchData.resultTitle}">[[${searchData.resultTitle}]]</a>
                                        <span  class="badge bg-gradient bg-success fw-light rounded-3 small">用户</span>
                                    </div>
                                </div>
                                <a class="flex-shrink-0 text-black-50 cv-link" th:href="'/profile/' + ${searchData.member.userId}+'/content'"  th:title="${searchData.member.userName}">
                                    <img class="lazyload img rounded rounded-right cv-icon-50" th:data-src="${searchData.member.via}" th:alt="${searchData.member.userName}">
                                </a>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="col-lg-3">
                <div th:include="fragments/index::global_search"></div>
                <div class="card card-body shadow-sm border-bottom border-2 border-top-0 border-start border-end-0 p-2 mb-2">
                    <div class="fw-normal border-bottom mb-2 text-black-50">搜索结果</div>
                    <div>一共搜到了<span style="color: #00a8c6" th:text="${searchIndexDto.total}"></span>条相关数据</div>
                </div>
                <div th:include="fragments/index::google_right_ad"></div>
            </div>
        </div>
    </div>
</div>
</html>
